<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('特殊人员登记新增')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>

</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-tsgjj-add" AUTOCOMPLETE="OFF">
        <input id="pzid" name="pzid" type="hidden"/>
        <input id="eid" name="eid" type="hidden"/>
        <input id="peid" name="peid" type="hidden"/>
        <input id="depId" name="depId" type="hidden"/>
        <input id="compId" name="compId" type="hidden"/>
        <input id="jobId" name="jobId" type="hidden"/>
        <input id="empStatus" name="empStatus" type="hidden"/>

        <div class="form-group">
            <label class="col-sm-3 control-label">工号：</label>
            <div class="col-sm-8">
                <input name="badge" id="badge" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">姓名：</label>
            <div class="col-sm-8">
                <input name="name" id="name" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">公司名称：</label>
            <div class="col-sm-8">
                <input name="compName" id="compName" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">部门名称：</label>
            <div class="col-sm-8">
                <input name="depName" id="depName" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">岗位名称：</label>
            <div class="col-sm-8">
                <input name="jobName" id="jobName" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">员工状态：</label>
            <div class="col-sm-8">
                <input name="empStatusName" id="empStatusName" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">入职日期：</label>
            <div class="col-sm-8">
                <input name="joinDate" id="joinDate" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">薪资区域：</label>
            <div class="col-sm-8">
                <input name="pzidName" id="pzidName" class="form-control" type="text" disabled="disabled">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">公积金个人承担部分：</label>
            <div class="col-sm-8">
                <input name="amount" id="amount" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">公积金公司承担部分：</label>
            <div class="col-sm-8">
                <input name="amount1" id="amount1" class="form-control" type="text" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <textarea name="remark" id="remark" class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "welfare/tsgjj";

    $(function () {
        $("#badge").blur(function () {
            badge = $("#badge").val();
            if(badge == '' || badge == null){
                return;
            }
            $.ajax({
                async: false,
                url: prefix + "/findEmpInfo",
                data: {
                    badge: badge
                },
                type: "post",
                dataType: "json",
                success: function (data) {
                    if(data.msg == 'error'){
                        $.modal.alertWarning("根据员工编号未找到该员工!");
                    }
                    $("#name").val(data.name);
                    $("#compName").val(data.compname);
                    $("#depName").val(data.departname);
                    $("#jobName").val(data.jobname);
                    $("#empStatusName").val(data.empStatusName);
                    $("#joinDate").val(data.joinDate);
                    $("#pzidName").val(data.PZName);

                    $("#pzid").val(data.pzid);
                    $("#eid").val(data.eid);
                    $("#peid").val(data.peid);
                    $("#depId").val(data.DepID);
                    $("#compId").val(data.CompID);
                    $("#jobId").val(data.JobID);
                    $("#empStatus").val(data.empStatus);
                    $("#amount").val();
                    $("#amount1").val();
                    $("#remark").val();

                    console.log(data);
                },
            });
        });
    })

    function submitHandler() {
        add();
    }

    function add() {
        $('#name').attr("disabled",false);
        $('#compName').attr("disabled",false);
        $('#depName').attr("disabled",false);
        $('#jobName').attr("disabled",false);
        $('#empStatusName').attr("disabled",false);
        $('#joinDate').attr("disabled",false);
        $('#pzidName').attr("disabled",false);
        if ($.validate.form()) {
            var datas = $("#form-tsgjj-add").serializeArray();
            datas.push({"id": "pzid", "value": $("#pzid").val()});
            datas.push({"id": "eid", "value": $("#eid").val()});
            datas.push({"id": "peid", "value": $("#peid").val()});
            datas.push({"id": "depId", "value": $("#depId").val()});
            datas.push({"id": "compId", "value": $("#compId").val()});
            datas.push({"id": "jobId", "value": $("#jobId").val()});
            datas.push({"id": "amount", "value": $("#amount").val()});
            datas.push({"id": "amount1", "value": $("#amount1").val()});
            datas.push({"id": "remark", "value": $("#remark").val()});
            datas.push({"id": "empStatus", "value": $("#empStatus").val()});

            datas.push({"id": "name", "value": $("#name").val()});
            datas.push({"id": "compName", "value": $("#compName").val()});
            datas.push({"id": "depName", "value":  $("#depName").val()});
            datas.push({"id": "jobName", "value": $("#jobName").val()});
            datas.push({"id": "empStatusName", "value": $("#empStatusName").val()});
            datas.push({"id": "joinDate", "value": $("#joinDate").val()});
            datas.push({"id": "pzidName", "value": $("#pzidName").val()});
            $.operate.save(prefix + "/add/tsgjj", datas);
        }
    }

</script>
</body>
</html>